<template>
  <div 
    v-if="visible" 
    class="loading-spinner" 
    :class="{ 'loading-fullscreen': fullscreen, 'loading-transparent': transparent }"
  >
    <div class="spinner-container">
      <div class="spinner" :style="spinnerStyle"></div>
      <div v-if="text" class="spinner-text">{{ text }}</div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'LoadingSpinner',
  props: {
    visible: {
      type: Boolean,
      default: true
    },
    fullscreen: {
      type: Boolean,
      default: false
    },
    transparent: {
      type: Boolean,
      default: false
    },
    color: {
      type: String,
      default: '#1890ff'
    },
    size: {
      type: Number,
      default: 36
    },
    text: {
      type: String,
      default: ''
    }
  },
  computed: {
    spinnerStyle() {
      return {
        width: `${this.size}px`,
        height: `${this.size}px`,
        borderTopColor: this.color
      }
    }
  }
}
</script>

<style scoped>
.loading-spinner {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(255, 255, 255, 0.7);
  z-index: 1000;
}

.loading-fullscreen {
  position: fixed;
}

.loading-transparent {
  background-color: transparent;
}

.spinner-container {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.spinner {
  border: 3px solid rgba(0, 0, 0, 0.1);
  border-top: 3px solid #1890ff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.spinner-text {
  margin-top: 12px;
  font-size: 14px;
  color: #333;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
</style> 